package com.zhiyou100.api.set_demo;

/**
 * 自定义的类是不自带比较功能的，我们可以让其实现Comparable比较接口
 */
public class Student implements Comparable<Student>{
    //自定义比较功能
    @Override
    public int compareTo(Student o) {
        return o.getAge() - this.getAge();
    }

    private String name;
    private int age;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Student() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


}
